// ITI 1120 Fall 2006, Lab 11, Example 2


/**
 * This class allows the user to enter line endpoints, and prints
 * the line object, and the length and slope of the line.  Then,
 * the user is asked for x and y distances to translate the line.
 * The line is translated, and then the line info, length, and slope
 * are printed again.
 */

class LineTest
{
    public static void main( String[] args )
    {
        // DECLARE VARIABLES / DATA DICTIONARY
        
        double[] lineInput;
        double xs;
        double ys;
        double xe;
        double ye;
        double tx;
        double ty;
        Line aLine;

        // PRINT IDENTIFICATION INFORMATION
        
        System.out.println();
        System.out.println("ITI 1120 Fall 2005, Lab 11, Example 2");
        System.out.println("Name: Diana Inkpen, Student# 123456");

        // BODY OF ALGORITHM
        
        System.out.println();
        System.out.print( "Enter the x and y coordinates " );
        System.out.print( "of the start of a line:  " );

        lineInput = ITI1120.readDoubleLine( );
        xs = lineInput[0];
        ys = lineInput[1];

        System.out.print( "Enter the x and y coordinates " );
        System.out.print( "of the end of the line:  " );

        lineInput = ITI1120.readDoubleLine( );
        xe = lineInput[0];
        ye = lineInput[1];

        aLine = new Line();
        aLine.setPoints( xs, ys, xe, ye );

        System.out.println(aLine);
        // Equivalent to:
        // aLine.printLineInfo( );

        System.out.println( "The length of the line is " + aLine.length() );
        System.out.println( "The slope of the line is " + aLine.slope() );

        System.out.print( "Enter the x and y distances " );
        System.out.print( "to translate the line:  " );

        lineInput = ITI1120.readDoubleLine( );
        tx = lineInput[0];
        ty = lineInput[1];

        aLine.translate( tx, ty );
        
        System.out.println(aLine);
        // equivalent to: 
        // aLine.printLineInfo( );

        System.out.println( "The length of the line is " + aLine.length() );
        System.out.println( "The slope of the line is " + aLine.slope() );
    }
}
        
        
